<?php
/**
 * @author Tuong Tran <tuong.tran@outlook.com>
 */
Yii::import('backend.modules.cms.models.*');
class PageController extends Controller{
    public $layout = 'column1';

    /**
     * allow view post
     * @param type $alias
     */
    public function actionView($alias){
        //get model with post type
        $model = Post::model()->find('`post_type` = :type AND `alias` = :alias', array(
            ':type' => 'page',
            ':alias' => $alias
        ));

        if(!$model){
            //404
            throw new CHttpException(404, 'Page was not exists!');
        }

        //seo support
        $this->description = $model->meta_description;
        $this->keywords = $model->meta_keywords;

        //render layout
        $this->render('view', array(
            'model' => $model
        ));
    }
}